package com.bdqn.servlet;

import com.bdqn.service.BrandService;
import com.bdqn.service.impl.BrandServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/deleteBrandServlet")
public class DeleteServlet extends HttpServlet {
    private BrandService brandService = new BrandServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=UTF-8");
        //获取挂参数值
        String id = req.getParameter("id");
        System.out.println("id = " + id);
        boolean flag = brandService.delete(id);
        if (flag){
            resp.getWriter().write("删除成功");
        }else {
            resp.getWriter().write("删除失败");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
